package com.lagou;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class FileReducer extends Reducer<FileBean, NullWritable,FileBean,NullWritable> {
    int num = 1;
    //基本上key都是不一样的 所有会有好多个reduce方法 但是为了防止key判断的相同 进入一个key的values里 我们还是遍历values比较稳妥
    @Override
    protected void reduce(FileBean key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        for (NullWritable value : values) {
            key.setId(num);
            num++;
            context.write(key,value);
        }
    }
}
